package my.example.samplegridview;

import java.util.Vector;

import my.example.samplegridview.modal.product;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.GridView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

public class whatsnew extends Activity {
	
	public static int requestcode = 900;
	private ProductAdapter pa ;
	public OrderPreviewAdapter opa;
	private headerbarmain hbm;
	
	public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	this.setContentView(R.layout.whatsnew);
    	
    	hbm = (headerbarmain)findViewById(R.id.whatsnewheaderbar);
    	hbm.setAct(this);
    	
    	Vector<product> productslist = product.SelectProducts(this, null, "date_added between datetime('now','localtime','-7 days') AND datetime('now' , 'localtime' )", null, null);
    	pa = new ProductAdapter(this , productslist , whatsnew.this);
    	Log.d("Items", String.valueOf(productslist.size()));
    	
    	GridView gv = (GridView)findViewById(R.id.whatsnewproductview);
    	gv.setAdapter(pa);
    }
	
	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data){
        if(resultCode == productdescription.activitycode){
        	hbm.reloadBatch();
        }
    }
    
    @Override
	protected void onResume(){
    	hbm.reloadBatch();
    	super.onResume();
    }
}
